﻿<%@ Page Language="C#" AutoEventWireup="true" Theme="Default" CodeBehind="TeShuYH.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS._8.QiTaGL.TeShuYH" %>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>特殊用户</title>
    <script src="/JS/AddEditCancel.js"></script>
    <script src="/JS/jquery.js"></script>
    <script type="text/javascript">
        function SelectChange() {
            CallBackControl.PerformCallback("select");
            SetStatus();
        }
        function Del() {
            if (confirm("确定要删除吗！？")) {
                CallBackControl.PerformCallback("del");
                SetStatus();
            }
        }
        function Save() {
            CallBackControl.PerformCallback("save");
            SetStatus();
        }
        function CallBackControlComplete(msg) {
            var list = msg.split('|');
            var type = list[0];
            var code = list[1];
            var err = list[2];

            if (type == "select") {
                if (code > 0) {
                    txtYongHuH.SetText(list[3]);
                    txtYongHuM.SetText(list[4]);
                }
            }
            else if (type == "del") {
                if (code > 0) {
                    alert("操作成功");
                    BtnSearch.OnClick();
                }
                else {
                    alert("操作失败");
                }
            }
            else if (type == "save") {
                if (code > 0) {
                    alert("保存成功");
                    BtnSearch.OnClick();
                }
                else if (code == -1) {
                    alert("用户号输入错误");
                }
                else if (code == -3) {
                    alert("该用户已存在特殊用户中");
                }
                else {
                    alert("保存失败");
                }
            }

        }
        function SetStatus(type) {

            if (type == "add") {
                txtYongHuH.SetEnabled(true);
                BtnAdd.SetEnabled(false);
                BtnDel.SetEnabled(false);
                BtnSave.SetEnabled(true);
                BtnCannel.SetEnabled(true);
                btnChaKan.SetEnabled(true);
            }
            else if (type == "save") {
                CallBackControlComplete("save");
            }
            else if (type == "del") {
                CallBackControlComplete("del");
            }
            else {
                txtYongHuH.SetEnabled(false);
                BtnAdd.SetEnabled(true);
                BtnDel.SetEnabled(true);
                BtnSave.SetEnabled(false);
                BtnCannel.SetEnabled(false);
                btnChaKan.SetEnabled(false);
            }
        }
        function SetSelectValue(yonghuh, yonghum) {

            txtYongHuH.SetText(yonghuh);
            txtYongHuM.SetText(yonghum);
        }
        function CannelControl() {

        }

        function openCenter2(openUrl, iWidth, iHeight) {
            var iTop = (window.screen.availHeight - 45 - iHeight) / 2; //获得窗口的垂直位置;
            var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
            window.showModalDialog(openUrl, window, "dialogHeight=" + iHeight + ";dialogwidth=" + iWidth + ";dialogLeft=" + iLeft + ";dialogTop=" + iTop + ";help=no;resizable=no;status=no;scrollbars=no;");
        }
        function OpenYHXX() {
            var url = "ChaXunYHXX.aspx";
            openCenter2(url, "500px", "600px");
        }
        $(function () {
            SetStatus();
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <dx:ASPxCallback ID="CallBackControl" ClientInstanceName="CallBackControl" runat="server" OnCallback="CallBackControl_Callback" ClientSideEvents-CallbackComplete="function(s,e){CallBackControlComplete(e.result);}"></dx:ASPxCallback>
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <div class="tabletitle1" align="center">
                        查询特殊用户
                    </div>
                    <table style="width: 96%; margin:0px auto">
                        <tr>
                            <td style="width: 40%; min-width: 230px">
                                <dx:ASPxGridView ID="gvList" SettingsBehavior-AllowSort="false" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="S_YONGHUH" Theme="Aqua1" Width="100%">
                                    <Columns>
                                        <dx:GridViewDataTextColumn Caption="用户号" Width="100px" FieldName="S_YONGHUH">
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn Caption="用户名" Width="300px" FieldName="S_YONGHUM"></dx:GridViewDataTextColumn>
                                    </Columns>
                                    <SettingsBehavior AllowSelectByRowClick="true" />
                                    <Settings VerticalScrollableHeight="315" HorizontalScrollBarMode="Auto" VerticalScrollBarMode="Auto" />
                                    <ClientSideEvents Init="function(s,e){AdjustSize(30,gvList);}" FocusedRowChanged="function(){SelectChange();}" />
                                </dx:ASPxGridView>
                            </td>
                            <td valign="top">
                                <table style="width: 96%; margin: 0px auto; margin-top: 100px">
                                    <tr>
                                        <td style="width: 80px">用户号：</td>
                                        <td>
                                            <dx:ASPxTextBox ID="txtYongHuH" Width="100%" ClientEnabled="false" ClientInstanceName="txtYongHuH" runat="server">
                                            </dx:ASPxTextBox>

                                        </td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>用户名：</td>
                                        <td>
                                            <dx:ASPxTextBox ID="txtYongHuM" Width="100%" ClientEnabled="false" ClientInstanceName="txtYongHuM" runat="server">
                                            </dx:ASPxTextBox>
                                        </td>
                                        <td>
                                            <dx:ASPxButton ID="btnChaKan" AutoPostBack="false" ClientEnabled="false" ClientInstanceName="btnChaKan" runat="server" Text="查询"
                                                UseSubmitBehavior="false">
                                                <ClientSideEvents Click="function(){OpenYHXX()}" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                    <tr style="height: 100px">
                                        <td colspan="3" align="center" valign="middle">
                                            <dx:ASPxButton ID="BtnAdd" ClientEnabled="false" ClientInstanceName="BtnAdd" runat="server" Text="新增"
                                                UseSubmitBehavior="false" AutoPostBack="false">
                                                <ClientSideEvents Click="function(s,e){SetStatus('add');}" />
                                            </dx:ASPxButton>
                                            <dx:ASPxButton ID="BtnSave" ClientEnabled="false" ClientInstanceName="BtnSave" runat="server" Text="保存"
                                                UseSubmitBehavior="false" AutoPostBack="false">
                                                <ClientSideEvents Click="function(){Save();}" />
                                            </dx:ASPxButton>
                                            <dx:ASPxButton ID="BtnDel" ClientEnabled="false" ClientInstanceName="BtnDel" runat="server" Text="删除"
                                                UseSubmitBehavior="false" AutoPostBack="false">
                                                <ClientSideEvents Click="function(){Del();}" />
                                            </dx:ASPxButton>
                                            <dx:ASPxButton ID="BtnCannel" ClientEnabled="false" AutoPostBack="false" ClientInstanceName="BtnCannel" runat="server" Text="放弃"
                                                UseSubmitBehavior="false">
                                                <ClientSideEvents Click="function(s,e){SelectChange();}" />
                                            </dx:ASPxButton>

                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>

                    </table>
                    <div style="display: none">
                        <dx:ASPxButton ID="BtnSearch" ClientInstanceName="BtnSearch" OnClick="BtnSearch_Click" runat="server" Text="放弃"
                            UseSubmitBehavior="false">
                        </dx:ASPxButton>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>
